import {getLocalToken, removeLocalToken, setLocalToken } from '@/utils/auth'
import { defineStore } from 'pinia'
import {ref} from 'vue'

// token存储
export const useUserStore = defineStore('hm-user', () => {
 const token=ref(getLocalToken()||'')
  const setToken  = (t: string)=>{
    token.value = t
    // 本地存一份
   setLocalToken(t)
  }
  const clearUserInfo = () => {
    token.value = ''
    removeLocalToken(); // 从本地存储中移除
  }
  return {token,setToken,clearUserInfo}
})
